package com.andong.controller;

import com.andong.annotations.AccessControl;
import com.andong.domain.dto.AdminAuthDTO;
import com.andong.domain.pojo.Result;
import com.andong.domain.vo.AdminAuthVO;
import com.andong.service.AdminAuthService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import java.util.List;

import static com.andong.utils.SystemConstant.*;

/**
 * 管理员权限表(AdminAuth)表控制层
 *
 * @author makejava
 * @since 2024-01-16 20:49:34
 */
@RestController
@RequestMapping("/adminAuth")
public class AdminAuthController {
    /**
     * 服务对象
     */
    @Resource
    private AdminAuthService adminAuthService;
    @GetMapping("/{id}")
    @AccessControl(roles = {ADMIN, SUPER_ADMIN})
    public Result getAuthById(@PathVariable Long id) {
        List<AdminAuthVO> adminAuthVOS = adminAuthService.getAuthById(id);
        return Result.success(adminAuthVOS);
    }

    @PostMapping()
    @AccessControl(roles = SUPER_ADMIN)
    public Result saveOrUpdate(@RequestBody AdminAuthDTO dto) {
        return adminAuthService.saveOrModify(dto);
    }
}

